/* GUI CONVERTED from icedit1.i (converter v1.76) Mon Apr  8 13:48:43 2002 */
/* icedit1.i - EDIT INVENTORY TRANS INPUT (NON-LOCATION-RELATED EDITS)        */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.7 $                                                           */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 6.0     LAST MODIFIED: 05/02/90    BY: WUG *D002*                */
/* REVISION: 6.0     LAST MODIFIED: 07/10/90    BY: WUG *D051*                */
/* REVISION: 6.0     LAST MODIFIED: 05/30/91    BY: RAM *D666*                */
/* REVISION: 7.0     LAST MODIFIED: 03/24/92    BY: pma *F089*                */
/* REVISION: 7.3     LAST MODIFIED: 09/02/93    BY: pxd *GE72*                */
/* REVISION: 7.5     LAST MODIFIED: 10/04/94    BY: MWD *J034*                */
/* REVISION: 8.5     LAST MODIFIED: 07/11/96    BY: *G1ZV* Julie Milligan     */
/* REVISION: 8.6     LAST MODIFIED: 05/20/98    BY: *K1Q4* Alfred Tan         */
/* REVISION: 9.1     LAST MODIFIED: 08/13/00    BY: *N0KS* Mark Brown         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.7 $    BY: Jean Miller           DATE: 04/06/02  ECO: *P056*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/************************************************************************/
/* {&site}                                                              */
/* {&part}                                                              */
/* {&lotserial}                                                         */
/* {&quantity}   In terms of pt_um                                      */
/* {&um}         The issue or receipt um                                */
/* {&transtype}  ""ISS-SO"", ""RCT-PO"" etc.                            */
/************************************************************************/


find pt_mstr where pt_part = {&part} no-lock no-error.
find si_mstr where si_site = {&site} no-lock no-error.

/* MAKE SURE LOT/SERIAL ENTERED FOR LOT OR SERIAL-CONTROLLED PARTS */
if available pt_mstr and index("LS",pt_lot_ser) > 0
   and {&quantity} <> 0
   and {&lotserial} = ""
then do:
   {pxmsg.i &MSGNUM=1119 &ERRORLEVEL=3}  /* LOT/SERIAL NUMBER REQUIRED */
   undo, retry.
end.

/* MAKE SURE UM = PT_UM IF SERIAL-CONTROLLED PARTS */
if available pt_mstr and pt_lot_ser = "S"
   and pt_um <> {&um}
then do:
   {pxmsg.i &MSGNUM=367 &ERRORLEVEL=3}  /* UM MUST BE EQUAL TO STOCKING */
   /* UM FOR SERIAL-CONTROLLED ITEMS */
   undo, retry.
end.

/* MAKE SURE QTY IS 1, 0, OR -1 FOR SERIAL-CONTROLLED PARTS */
if available pt_mstr and pt_lot_ser = "S"
   and {&quantity} <> 1
   and {&quantity} <> -1
   and {&quantity} <> 0
then do:
   {pxmsg.i &MSGNUM=314 &ERRORLEVEL=3}  /* QUANTITY MUST BE -1 OR 1 */
   undo, retry.
end.

/* MAKE SURE THE SELECTED SITE EXISTS */
if not available si_mstr then do:
   {pxmsg.i &MSGNUM=708 &ERRORLEVEL=3}  /* SITE DOES NOT EXIST */
   undo, retry.
end.

/* VALIDATE SITE SECURITY FOR USER GROUP */
{gprun.i ""gpsiver.p""
   "(input si_site, input recid(si_mstr), output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.

if return_int = 0 then do:
   {pxmsg.i &MSGNUM=725 &ERRORLEVEL=3}  /* USER DOES NOT HAVE ACCESS */
   /* TO THIS SITE              */
   undo, retry.
end.

/* MAKE SURE THAT ITEM STATUS ALLOWS TRANSTYPE */
if available pt_mstr then do:
   if can-find(first isd_det where
                     isd_status = string(pt_status,"x(8)") + "#"
                 and isd_tr_type = {&transtype})
   then do:
      /* Restricted Procedure for Item Status code */
      {pxmsg.i &MSGNUM=358 &ERRORLEVEL=3 &MSGARG1=pt_status}
      undo, retry.
   end.
end. /* available pt_mstr */
